<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<h2 mat-dialog-title>{{ isNew ? 'Add' : 'Edit' }} Parameter</h2>
<form class="edit-parameter-form" [formGroup]="editParameterForm">
    <mat-dialog-content>
        <div class="mb-2">
            <mat-form-field>
                <mat-label>Name</mat-label>
                <input matInput formControlName="name" type="text" />
                @if (name.invalid) {
                    <mat-error>{{ getNameErrorMessage() }}</mat-error>
                }
            </mat-form-field>
        </div>
        <div>
            <mat-form-field>
                <mat-label>
                    Value
                    <i
                        class="fa fa-info-circle"
                        nifiTooltip
                        [tooltipComponentType]="TextTip"
                        tooltipInputData="Parameter values do not support Expression Language or embedded parameter references."></i>
                </mat-label>
                <textarea
                    matInput
                    formControlName="value"
                    type="text"
                    [class.sensitive]="showSensitiveHelperText"
                    (keydown)="clearSensitiveHelperText()"></textarea>
            </mat-form-field>
        </div>
        <div class="-mt-4 mb-4">
            <mat-checkbox formControlName="empty" (change)="setEmptyStringChanged()">Set empty string</mat-checkbox>
        </div>
        <div class="flex flex-col mb-4">
            <label>Sensitive Value</label>
            <mat-radio-group formControlName="sensitive">
                <mat-radio-button [value]="true">Yes</mat-radio-button>
                <mat-radio-button [value]="false">No</mat-radio-button>
            </mat-radio-group>
        </div>
        <div>
            <mat-form-field>
                <mat-label>Description</mat-label>
                <textarea matInput formControlName="description" type="text"></textarea>
            </mat-form-field>
        </div>
    </mat-dialog-content>
    @if ({ value: (saving$ | async)! }; as saving) {
        <mat-dialog-actions align="end">
            <button mat-button mat-dialog-close>Cancel</button>
            <button
                mat-flat-button
                [disabled]="editParameterForm.invalid || saving.value || editParameterForm.pending"
                (click)="okClicked()">
                <span *nifiSpinner="saving.value">Ok</span>
            </button>
        </mat-dialog-actions>
    }
</form>
